<template>
	<view class="page addNews">
		<view class="form-container mb-30">
			<view class="form-item line-b" >
				<view class="label" >账号<text class="c-ff6">*</text></view>
				<view class="right">
					<input type="text" placeholder="请输入" v-model="pnum"/>
				</view>
			</view>
			<view class="form-item line-b" >
				<view class="label" >密码<text class="c-ff6">*</text></view>
				<view class="right">
					<input type="text" placeholder="请输入" v-model="password"/>
				</view>
			</view>
		<view class="pdtb-30 bg-f fz24 c-ff6 tac" @click="ok">绑定</view>
	</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				id:'',
				info:'',
				cname:'',
				pnum:'',
				danw:'',
				phone:'',
				password:'',
				items: [{
					value: '1',
					name: '提交审核'
				},
				{
					value: '2',
					name: '密钥绑定',
					checked: 'true'
				}],
				current: 1,
				tjfs:false
			}
		},
		onLoad(e) {
			this.id = uni.getStorageSync('uid');
			if(uni.getStorageSync('uid')==''){
				uni.navigateTo({
					url:"/pages/index/index"
				})
			}
		},
		created() {
				this.init();
		},
		methods: {
			 radioChange: function(evt) {
				 if(evt.detail.value==1){
					 this.tjfs = false
				 }else{
					 this.tjfs = true
				 }
				// console.log(evt)
				for (let i = 0; i < this.items.length; i++) {
					if (this.items[i].value === evt.detail.value) {
						this.current = i;
						break;
					}
				}
			},
			async init(){
				let data = {
					id:this.id
				}
				let res =  await this.$api.getuserinfo(data)
				this.info = res.data.data
				this.id = res.data.data.id
				
			},
			async ok(){
				 
						let data = {
							pnum:this.pnum,
							password:this.password,
							current:this.current,
							id:this.id,
						}
						let res =  await this.$api.edituserinfo(data)
						console.log(res)
						console.log(res.data.code)
						if(res.data.code==0){
							uni.navigateTo({
								url:'/pages/index/index'
							})
						}else{
							uni.showToast({
							  title: res.data.msg,	
							  icon:'none',
							  duration: 2000
							});
						}
			}
		}
	}
</script>

<style lang="scss">
.addNews {
	&.page {
		padding: 14upx 0;
		height: auto;
	}
	textarea {
		border: 1upx solid #E1E1E1;
		padding: 10upx;
		border-radius: 10upx;
	}
	.linght{
		height: 60upx;
		line-height: 60upx;
	}
}
</style>
